/* ************************************************************************** */^M
/* Example of a syndication feed reader using the Project Rome API with */^M
/* BSF4ooRexx */^M
/* current version of Rome: rome1.0.jar https://rome.dev.java.net/ */^M
/* You need to implement this API plus the JDOM API */^M
/* jdom.jar , you can find this at https://jdom.org/ */^M
/* */^M
/* This example retrieves several feeds from a URI and aggregates them */^M
/* to a single one (in combination with a grafical interface) */ ^M
/* created by Martin Stoppacher date: 26.12.2009 (c) 2009 */^M
/* license:ÊÊÊÊLGPL 3.0ÊÊÊÊÊÊÊused versions: Java 1.6, ooRexx 4.0, Bsf4ooRexx */^M
/* (Lesser Gnu Public License version 3.0), */^M
/* cf. <http://www.gnu.org/licenses/lgpl.html> */^M
/* ************************************************************************** */^M
^M
say hello this aggregates a syndfeeds^M
^M
^M
/* this creates an array of feed urls which will later be aggregated */^M
say type in the urls _ to end type in _ end _^M
tmpColl = .array ~new^M
insert = .urlinsert~new^M
i = 0^M
^M
frame=.bsf~new("java.awt.Frame", "Please enter the url")^M
frame~bsf.addEventListener( 'window', 'windowClosing', 'call BSF "exit"')^M
frame~setLayout( .bsf~new("java.awt.GridLayout",3,1) )^M
tf=.bsf~new("java.awt.TextField", "http://rss.orf.at/fm4.xml", 50)^M
^M
but=.bsf~new('java.awt.Button', 'insert url')^M
but~bsf.addEventListener('action', '', 'i=i+1')^M
but~bsf.addEventListener('action', '', 'insert~insert(tmpColl, tf~getText, i) ') ^M
but_end=.bsf~new('java.awt.Button', 'end insert')^M
but_end~bsf.addEventListener('action', '', 'call create')^M
frame~add(tf)
frame~add(but)
frame~add(but_end)
frame~~pack~~show~~toFront^M
do forever^M
INTERPRET .bsf~bsf.pollEventText^M
if result="SHUTDOWN, REXX !" then leave^M
end^M
^M
/* this retrieves the type of the aggregated feed */^M
create:^M
^M
frame~toBack^M
^M
inserttype = .typeinsert~new^M
typet = inserttype~getframe^M
^M
fileName2 = "test5_aggregated_feed" typet ^M
^M
call Syssleep 1^M
inserttype~closeframe^M
frame~~toFront^M
^M
say 'Your crated feed starts hear :'^M
^M
feed=.bsf~new("com.sun.syndication.feed.synd.SyndFeedImpl")^M
/* using syndfeedImpl to creat a feed using the independent object model */^M
feed~setFeedType(typet)^M
/* sets the type of this feed */^M
^M
/* this aggregates the URI names to one String */^M
do x=i to 1 by -1^M
desc = "Anonymous Aggregated Feed from _ "^M
desc = desc || tmpColl~at(x)^M
end^M
^M
feed~setTitle("Aggregated Feed")^M
feed~setDescription(desc)^M
feed~setAuthor("Martin Stoppacher")^M
feed~setLink("http://martinstoppacher.com")^M
/* create some entries for the feed by using the SyndFeed methods */^M
^M
/* creates a Java array list for the entries of the feed*/^M
entries =.bsf~new("java.util.ArrayList")^M
^M
/* this uses the URL array to retrieve the entries fro the feeds */^M
/* and add them to the entries array */^M
^M
do y=i to 1 by -1^M
feedUrl=.bsf~new("java.net.URL",tmpColl~at(y))^M
input=.bsf~new("com.sun.syndication.io.SyndFeedInput")^M
xmlr=.bsf~new("com.sun.syndication.io.XmlReader", feedUrl)^M
infeed=input~build(xmlr)^M
entries~addAll(infeed~getEntries()) ^M
end^M
^M
/* output of the aggregated feeds */ ^M
feed~setEntries(entries)^M
^M
writer=.bsf~new("java.io.FileWriter",fileName2)^M
output=.bsf~new("com.sun.syndication.io.SyndFeedOutput") ^M
output~output(feed,writer)^M
writer~close()^M
^M
say output~outputString(feed,1) /* usage of pretty print(0 yes or 1 no) */^M
^M
--call BSF "exit" /* optional exit point */^M
^M
PP : RETURN "[" || ARG(1)|| "]"^M
^M
::requires BSF.cls^M
^M
::class urlinsert^M
^M
::method insert^M
use arg tmpColl, url, i^M
tmpColl[i] = url^M
^M
say "your urls are :"^M
SAY tmpColl~string || ":"^M
DO item OVER tmpColl^M
SAY "[" || item || "]"^M
END^M
^M
::class typeinsert^M
^M
:: method getframe^M
expose frame2^M
^M
frame2=.bsf~new("java.awt.Frame", "Please enter the FeedType")^M
/* ss_0.90, rss_0.91, rss_0.92, rss_0.93, rss_0.94, ^M
rss_1.0 rss_2.0 or atom_0.3 */^M
frame2~bsf.addEventListener( 'window', 'windowClosing', 'call BSF "exit"')^M
frame2~setLayout( .bsf~new("java.awt.GridLayout",2,1) )^M
type=.bsf~new("java.awt.TextField", "rss_1.0", 50)^M
frame2~add(type)^M
but2=.bsf~new('java.awt.Button', 'insert FeedType')^M
frame2~add(but2)^M
but2~bsf.addEventListener('action', '', 'return type~getText ')^M
frame2~~pack~~show~~toFront^M
INTERPRET .bsf~bsf.pollEventText^M
--if result="SHUTDOWN, REXX !" then leave^M
^M
:: method closeframe^M
expose frame2^M
frame2~~toBack^M
drop frame2